<?php
namespace api;
use api\jeu\map as nsMap;

error_reporting(E_ALL);

define("GAME", true);

include 'master.php';

$map = new nsMap\map(5,5);

$map->setCase(2,3,new nsMap\SimpleCases());
$map->setCase(3,2,new nsMap\SimpleCases());
$map->setCase(3,5,new nsMap\SimpleCases());
$map->setCase(5,4,new nsMap\SimpleCases());

$map->getCase(2,3)->addObject('test','A');
$map->getCase(3,2)->addObject('test','B');
$map->getCase(3,5)->addObject('test','C');
$map->getCase(5,4)->addObject('test','D');

echo $map->toString();

echo '<table border="1">';
for($x=0;$x<=$map->width;$x++) {
	echo '<tr>';
	for($y=0;$y<=$map->height;$y++) {

		if($x==0 && $y==0) {
			echo '<th>X</th>';
		} elseif ($x == 0){
			echo '<th>'.$y.'</th>';
		} elseif ($y == 0){
			echo '<td>'.$x.'</td>';
		} else {
			$case = $map->getCase($x,$y);
			if(!$case) {
				echo '<td>.</td>';
			} else
			{
				echo '<td>'.$case->getObject('test').'</td>';
			}
		}
	
	}
	echo '</tr>';
}
echo '</table>';